<?php

if (stripos($_SERVER['SERVER_NAME'], 'dev.') !== false) {
    $login = "admin";
    $password = 'x8group';
    if (!isset($_SERVER['PHP_AUTH_USER'])) {
        header("WWW-Authenticate: Basic realm=\"Login to Admin Panel");
        header("HTTP/1.0 401 Unauthorized");
        die("Access only for administrators!\n");
        exit;
    }
    if ($_SERVER['PHP_AUTH_USER'] != $login and $_SERVER['PHP_AUTH_PW'] != $password) {
        header("WWW-Authenticate: Basic realm=\"Login to Admin Panel");
        header("HTTP/1.0 401 Unauthorized");
        die("Access only for administrators!\n");
    }
}

$yii = dirname(__FILE__) . '/../yii/yii.php';
$config = dirname(__FILE__) . '/protected/config/main.php';

if (stripos($_SERVER['SERVER_NAME'], '.ru') === false) {
    ini_set("display_errors", 1);
    error_reporting(E_ALL);
    defined('YII_DEBUG') or define('YII_DEBUG', true);
    defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
} else {
    ini_set("display_errors", 1);
    error_reporting(E_ALL);
}

require_once($yii);
Yii::createWebApplication($config)->run();
//$time = microtime(true) - $start;
//printf('Скрипт выполнялся %.4F сек.', $time);